package stu.aistar.day03.homework;

/**
 * 最大公约数
 */
public class GongYueShu {
    public static void main(String[] args) {
        System.out.println(CommonDivisor(20,12));
    }
    public static int CommonDivisor(int a,int b){
        int com;
        while (true){
            if(a<b){
                a = a^(a=b)^b;
            }
            com = a%b;
            a=b;
            b=com;
            if (com==0){
                break;
            }

        }
        return a;
    }
}
